package com.easywan.manager.inteceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

public class ManagerInteceptor implements HandlerInterceptor{

	public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3)
			throws Exception {
		
	}

	public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3)
			throws Exception {
		
	}

	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object arg2) throws Exception {
		Boolean result = false;
		String uri = request.getRequestURI().replace(".html", "");
		String lowerUri = uri.toLowerCase();
		System.out.println(uri);
		if(lowerUri.indexOf("menuelist") > 0){
			return true;
		}
		if(lowerUri.indexOf("list") >= 0){//普通页面  只要menue结尾
			//普通查询页面  只要转发
			
		}else if(lowerUri.indexOf("menue") >= 0) {//查询事件
			request.getRequestDispatcher("/WEB-INF/views"+uri+".jsp").forward(request, response);
		}else{
			result = true;
		}
		
		return result;
	}

}
